<link href="<?php echo base_url(); ?>public/styles/style.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function(){
$("#btnSearch").click(function(){
	$depart = $("#depart").val();
	$return = $("#return").val();
	if($("#train").val() == 0){ alert("Please select a train"); return false;}
	if($return == ""){ alert("Please select return date");$("#return").focus(); return false;}
	if(document.getElementById("roundtrip").checked){
		if($depart > $return){alert("Return date must be greater than depart"); return false;}
	}
});
});
function typetick($val){
	$obj = document.getElementById("return");
	$calimg = document.getElementById("calreturn");
	if($val == 1){$obj.disabled = "disabled";
	$calimg.style.opacity = 0.5
	}else{$obj.disabled = "";$calimg.style.opacity = 1}
}
</script>
<form id="frmSearch" name="frmSearch" action="<?php echo base_url(); ?>check-ticket.html" method="post">
  <div class="boxLeft clearfix">
    <h2 class="titColLeft">TICKET SEARCH</h2>
    <div class="boxSearchLeft clearfix">
      <p class="line12">
        <label class="radio2">
          <input type="radio" name="type" value="2" id="roundtrip" checked="checked" onclick="typetick(this.value)">
          <span class="Fl">Roundtrip</span> </label>
        <label class="radio2 pad0">
          <input type="radio" name="type" value="1" <?php if(isset($typetick) && $typetick == 1){ echo "checked='checked'";} ?> onclick="typetick(this.value)">
          <span class="Fl">One Way</span> </label>
        <input type="hidden" value="2" name="radiotype" id="radiotype">
        <input type="hidden" value="" name="return-disble" id="return-disble">
      </p>
      <p class="textS"><a>(List all train)</a></p>
      <select class="ipS192" id="train" name="train">
        <option value="0">Please select a train</option>
        <?php if(isset($trains)){ foreach($trains as $train){ ?>
        <option value="<?php echo $train['train_id']; ?>" <?php if(isset($trainid) && $trainid == $train['train_id']){ echo "selected='selected'";}?>><?php echo $train['train_name']; ?></option>
        <?php } } ?>
      </select>
      <p class="textS">Depart</p>
      <p class="line">
        <?php 
			$now = strtotime(date("m/d/Y"));
			$tomorow = date('m/d/Y',mktime(0,0,0,date('m',$now),date('d',$now) + 1,date('Y',$now)));
			$nexttomor = date('m/d/Y',mktime(0,0,0,date('m',$now),date('d',$now) + 2,date('Y',$now)));
		?>
        <input type="text" value="<?php if(isset($curstart)){ echo $curstart;}else{echo $tomorow;} ?>" class="ipS125 hadate" id="depart" name="depart" readonly="readonly" />
        <img class="ui-datepicker-trigger" src="<?php echo base_url(); ?>public/images/calenda.jpg" alt="..." title="..."> </p>
      <p class="textS">Return</p>
      <p class="line">
        <input type="text" value="<?php if(isset($curendate)){ echo $curendate;}else{echo $nexttomor;} ?>" class="ipS125 hadate" id="return" name="return" readonly="readonly" <?php if(isset($typetick) && $typetick == 1){ echo 'disabled="disabled"';} ?>/>
        <img class="ui-datepicker-trigger" src="<?php echo base_url(); ?>public/images/calenda.jpg" id="calreturn" alt="..." title="..."  <?php if(isset($typetick) && $typetick == 1){ echo 'disabled="disabled"';} ?>/> </p>
      <div class="travellers230">
        <div class="search40" style="width:100%;">
          <p class="textS center" style="text-align: left;">Number of Passengers</p>
          <!--input type="text" class="ipS40" value="<?php if(isset($adults)){ echo $adults;}else{echo 1;} ?>" id="adult" name="adult"-->
          <select name="adult">
          	<?php for($i=1;$i<=10;$i++){ ?>
          		<option value="<?php echo $i; ?>" <?php if(isset($adults) && $adults == $i){ echo "selected='selected'";} ?>><?php echo $i; ?></option>
            <?php } ?>
          </select>
          </div>
      </div>
      <input type="submit" class="btn btn-red" id="btnSearch" name="okie" value="Go" style="color:#FFF">
      <p style="width:100%; color:red; float:left;padding-top:10px;">
        <label id="error"></label>
      </p>
      <div class="botSearch line">
        <div class="dash-small">All train services are provided by Train Companies.</div>
        <div class="dash-small">Cancellation and change policy<br>
          are noted in our Terms &amp; Conditions</div>
        <span> <img alt="" src="<?php echo base_url(); ?>public/images/pay1.jpg"> <img alt="" src="<?php echo base_url(); ?>public/images/pay2.jpg"> <img alt="" src="<?php echo base_url(); ?>public/images/pay3.jpg"> <img alt="" src="<?php echo base_url(); ?>public/images/pay4.jpg"> <img alt="" src="<?php echo base_url(); ?>public/images/pay5.jpg"> </span> </div>
    </div>
  </div>
</form>